<?php

namespace app\listener;

use think\db\BaseQuery;
use think\facade\Db;

class AppInit
{
    public function handle($event): void
    {
        Db::event('after_insert', function (BaseQuery $query) {
            operate_log('新增', $query->getTable(), $query->getLastInsID());
        });

        Db::event('after_update', function (BaseQuery $query) {
            operate_log('编辑', $query->getTable());
        });

        Db::event('after_delete', function (BaseQuery $query) {
            operate_log('删除', $query->getTable());
        });
    }
}
